﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ControlModule.Models;

namespace ControlModule.Daos
{
    public class LabParameterDao
    {
        public static List<LabParameter> LoadParametersByLabworkId(int labworkId)
        {
            List<LabParameter> parameters = null;
            using (CmDbEntities db = new CmDbEntities())
            {
                parameters = (
                    from pp in db.LabParameter
                    from rlp in db.RelLabworkParameter
                    where rlp.ParameterId == pp.Id
                    where rlp.LabworkId == labworkId
                    select pp).ToList();
            }
            return parameters;
        }

        public static LabParameter GetById(int id)
        {
            LabParameter parameter = null;
            using (CmDbEntities db = new CmDbEntities())
            {
                parameter = (
                    from pp in db.LabParameter
                    where pp.Id == id
                    select pp).FirstOrDefault();
            }
            return parameter;
        }
    }
}